//
//  ToggleImageControl.m
//  TodaysPlan
//
//  Created by 篤史 寺田 on 11/11/22.
//  Copyright (c) 2011年 __MyCompanyName__. All rights reserved.
//

#import "ToggleImageControl.h"

@implementation ToggleImageControl
- (id)initWithFrame:(CGRect)frame {
	if (self = [super initWithFrame:frame]) {
		normalImage = [UIImage imageNamed: @"normal.png"];      //todo image changing!
		selectedImage = [UIImage imageNamed: @"selected.png"];  //todo image changing!
		imageView = [[UIImageView alloc] initWithImage: selectedImage];
        
		// set imageView frame
		[self addSubview:imageView];
		self.userInteractionEnabled = NO;
		[imageView release];
	}
	return self;
}

- (void)toggleOn:(BOOL)selected {
	imageView.image = (selected ? selectedImage : normalImage);
}

- (void)dealloc {
	NSLog(@"ToggleImageControl dealloc");
	[imageView release];
	[normalImage release];
	[selectedImage release];
    
	[super dealloc];
}

@end
